﻿/****************************** Module Header ******************************\
 * Module Name:  ExMethodForFormView.cs
 * Module Version:  1.0.0 (2011-9-30)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to extension webcontrol instance's method.  It supplies 
 * public static extension methods to load data or get othor control.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/

using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI.WebControls;

namespace UCF.Core.Web
{
    /// <summary>
    /// FormView服务器控件的扩展方法
    /// </summary>
    public static class ExMethodForFormView
    {
        /// <summary>
        /// FormView控件数据绑定
        /// </summary>
        /// <param name="formView"></param>
        /// <param name="iDataReader"></param>
        public static void LoadData(this FormView formView, ref IDataReader iDataReader)
        {
            formView.DataSource = iDataReader;
            formView.DataBind();
        }
        /// <summary>
        /// FormView对象加载数据源
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="formView"></param>
        /// <param name="entity"></param>
        public static void LoadData<T>(this FormView formView, ref T entity)
        {
            formView.DataSource = entity;
            formView.DataBind();
        }
    }
}
